package com.vision.sales.cm.data;

import static com.vision.core.cm.data.ApplicationId.Sales;
import static com.vision.core.cm.data.Domain.ADVANCE_PAYMENT;
import static com.vision.core.cm.data.Domain.APPLIED_ADVANCE_PAYMENT;
import static com.vision.core.cm.data.Domain.CHECK;
import static com.vision.core.cm.data.Domain.COLLECTION;
import static com.vision.core.cm.data.Domain.CREDIT_MEMO;
import static com.vision.core.cm.data.Domain.CUSTOMER;
import static com.vision.core.cm.data.Domain.DEBIT_MEMO;
import static com.vision.core.cm.data.Domain.DELIVERY_RECEIPT;
import static com.vision.core.cm.data.Domain.MONTHLY_TOTAL;
import static com.vision.core.cm.data.Domain.PRODUCT;
import static com.vision.core.cm.data.Domain.REPORT_COMMISSION;
import static com.vision.core.cm.data.Domain.REPORT_CUSTOMER_AGING;
import static com.vision.core.cm.data.Domain.REPORT_CUSTOMER_LEDGER;
import static com.vision.core.cm.data.Domain.REPORT_CUSTOMER_SALES;
import static com.vision.core.cm.data.Domain.REPORT_DELIVERY_RECEIPTS;
import static com.vision.core.cm.data.Domain.REPORT_INDIVIDUAL_SOA;
import static com.vision.core.cm.data.Domain.REPORT_OUTSTANDING_RECEIVABLES;
import static com.vision.core.cm.data.Domain.REPORT_PRODUCT_SALES;
import static com.vision.core.cm.data.Domain.REPORT_SALESMAN_SALES;
import static com.vision.core.cm.data.Domain.REPORT_INDIV_SALESMAN_SALES;
import static com.vision.core.cm.data.Domain.REPORT_INDIV_SALESMAN_COMM;
import static com.vision.core.cm.data.Domain.SALESMAN;
import static com.vision.core.cm.data.Domain.SALES_INVOICE;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import com.vision.core.cm.db.data.Permission;

/**
 * 
 * @author Mark
 *
 */
public interface SalesPermissions {
	
	// Product-related permissions
	Permission CreateProduct = new Permission(Sales, PRODUCT, "Create Product", "Allows creating of Products.");
	Permission ViewProduct = new Permission(Sales, PRODUCT, "View Product", "Allows viewing of Product information.");
	Permission UpdateProduct = new Permission(Sales, PRODUCT, "Update Product", "Allows updating of Product information.");
	Permission DeleteProduct = new Permission(Sales, PRODUCT, "Delete Product", "Allows deleting of Products.");
	Set<Permission> AllForProduct = new HashSet<Permission>( Arrays.asList(CreateProduct, ViewProduct, UpdateProduct, DeleteProduct) );
		
	// Salesman-related permissions
	Permission CreateSalesman = new Permission(Sales, SALESMAN, "Create Salesman", "Allows creating of Salesmen.");
	Permission ViewSalesman = new Permission(Sales, SALESMAN, "View Salesman", "Allows viewing of Salesman information.");
	Permission UpdateSalesman = new Permission(Sales, SALESMAN, "Update Salesman", "Allows updating of Salesman information.");
	Permission DeleteSalesman = new Permission(Sales, SALESMAN, "Delete Salesman", "Allows deleting of Salesmen.");
	Set<Permission> AllForSalesman = new HashSet<Permission>( Arrays.asList(CreateSalesman, ViewSalesman, UpdateSalesman, DeleteSalesman) );
	
	// Customer-related permissions
	Permission CreateCustomer = new Permission(Sales, CUSTOMER, "Create Customer", "Allows creating of Customers.");
	Permission ViewCustomer = new Permission(Sales, CUSTOMER, "View Customer", "Allows viewing of Customer information.");
	Permission UpdateCustomer = new Permission(Sales, CUSTOMER, "Update Customer", "Allows updating of Customer information.");
	Permission DeleteCustomer = new Permission(Sales, CUSTOMER, "Delete Customer", "Allows deleting of Customers.");
	Set<Permission> AllForCustomer = new HashSet<Permission>( Arrays.asList(CreateCustomer, ViewCustomer, UpdateCustomer, DeleteCustomer) );
	
	// Check-related permissions
	Permission CreateCheck = new Permission(Sales, CHECK, "Create Check", "Allows creating of Checks.");
	Permission ViewCheck = new Permission(Sales, CHECK, "View Check", "Allows viewing of Check information.");
	Permission UpdateCheck = new Permission(Sales, CHECK, "Update Check", "Allows updating of Check information.");
	Permission DeleteCheck = new Permission(Sales, CHECK, "Delete Check", "Allows deleting of Checks.");
	Set<Permission> AllForCheck = new HashSet<Permission>( Arrays.asList(CreateCheck, ViewCheck, UpdateCheck, DeleteCheck) );
	
	// MonthlyTotal-related permissions
	Permission ViewMonthlyTotal = new Permission(Sales, MONTHLY_TOTAL, "View monthly totals", "Allows viewing of monthly totals information.");
	Set<Permission> AllForMonthlyTotal = new HashSet<Permission>( Arrays.asList(ViewMonthlyTotal) );
	
	// AdvancePayment-related permissions
	Permission CreateAdvancePayment = new Permission(Sales, ADVANCE_PAYMENT, "Create AdvancePayment", "Allows creating of AdvancePayments.");
	Permission ViewAdvancePayment = new Permission(Sales, ADVANCE_PAYMENT, "View AdvancePayment", "Allows viewing of AdvancePayment information.");
	Permission UpdateAdvancePayment = new Permission(Sales, ADVANCE_PAYMENT, "Update AdvancePayment", "Allows updating of AdvancePayment information.");
	Permission DeleteAdvancePayment = new Permission(Sales, ADVANCE_PAYMENT, "Delete AdvancePayment", "Allows deleting of AdvancePayments.");
	Permission PostAdvancePayment = new Permission(Sales, ADVANCE_PAYMENT, "Post AdvancePayment", "Allows posting of AdvancePayments.");
	Set<Permission> AllForAdvancePayment = new HashSet<Permission>( Arrays.asList(CreateAdvancePayment, ViewAdvancePayment, UpdateAdvancePayment, DeleteAdvancePayment, PostAdvancePayment) );
	
	// AppliedAdvancePayment-related permissions
	Permission CreateAppliedAdvancePayment = new Permission(Sales, APPLIED_ADVANCE_PAYMENT, "Create AppliedAdvancePayment", "Allows creating of AppliedAdvancePayments.");
	Permission ViewAppliedAdvancePayment = new Permission(Sales, APPLIED_ADVANCE_PAYMENT, "View AppliedAdvancePayment", "Allows viewing of AppliedAdvancePayment information.");
	Permission UpdateAppliedAdvancePayment = new Permission(Sales, APPLIED_ADVANCE_PAYMENT, "Update AppliedAdvancePayment", "Allows updating of AppliedAdvancePayment information.");
	Permission DeleteAppliedAdvancePayment = new Permission(Sales, APPLIED_ADVANCE_PAYMENT, "Delete AppliedAdvancePayment", "Allows deleting of AppliedAdvancePayments.");
	Permission PostAppliedAdvancePayment = new Permission(Sales, APPLIED_ADVANCE_PAYMENT, "Post AppliedAdvancePayment", "Allows posting of AppliedAdvancePayments.");
	Set<Permission> AllForAppliedAdvancePayment = new HashSet<Permission>( Arrays.asList(CreateAppliedAdvancePayment, ViewAppliedAdvancePayment, UpdateAppliedAdvancePayment, DeleteAppliedAdvancePayment, PostAppliedAdvancePayment) );
	
	// DebitMemo-related permissions
	Permission CreateDebitMemo = new Permission(Sales, DEBIT_MEMO, "Create DebitMemo", "Allows creating of DebitMemos.");
	Permission ViewDebitMemo = new Permission(Sales, DEBIT_MEMO, "View DebitMemo", "Allows viewing of DebitMemo information.");
	Permission UpdateDebitMemo = new Permission(Sales, DEBIT_MEMO, "Update DebitMemo", "Allows updating of DebitMemo information.");
	Permission DeleteDebitMemo = new Permission(Sales, DEBIT_MEMO, "Delete DebitMemo", "Allows deleting of DebitMemos.");
	Permission PostDebitMemo = new Permission(Sales, ADVANCE_PAYMENT, "Post DebitMemo", "Allows posting of DebitMemos.");
	Set<Permission> AllForDebitMemo = new HashSet<Permission>( Arrays.asList(CreateDebitMemo, ViewDebitMemo, UpdateDebitMemo, DeleteDebitMemo, PostDebitMemo) );
	
	// CreditMemo-related permissions
	Permission CreateCreditMemo = new Permission(Sales, CREDIT_MEMO, "Create CreditMemo", "Allows creating of CreditMemos.");
	Permission ViewCreditMemo = new Permission(Sales, CREDIT_MEMO, "View CreditMemo", "Allows viewing of CreditMemo information.");
	Permission UpdateCreditMemo = new Permission(Sales, CREDIT_MEMO, "Update CreditMemo", "Allows updating of CreditMemo information.");
	Permission DeleteCreditMemo = new Permission(Sales, CREDIT_MEMO, "Delete CreditMemo", "Allows deleting of CreditMemos.");
	Permission PostCreditMemo = new Permission(Sales, ADVANCE_PAYMENT, "Post CreditMemo", "Allows posting of CreditMemos.");
	Set<Permission> AllForCreditMemo = new HashSet<Permission>( Arrays.asList(CreateCreditMemo, ViewCreditMemo, UpdateCreditMemo, DeleteCreditMemo, PostCreditMemo) );
	
	// DeliveryReceipt-related permissions
	Permission CreateDeliveryReceipt = new Permission(Sales, DELIVERY_RECEIPT, "Create DeliveryReceipt", "Allows creating of DeliveryReceipts.");
	Permission ViewDeliveryReceipt = new Permission(Sales, DELIVERY_RECEIPT, "View DeliveryReceipt", "Allows viewing of DeliveryReceipt information.");
	Permission UpdateDeliveryReceipt = new Permission(Sales, DELIVERY_RECEIPT, "Update DeliveryReceipt", "Allows updating of DeliveryReceipt information.");
	Permission DeleteDeliveryReceipt = new Permission(Sales, DELIVERY_RECEIPT, "Delete DeliveryReceipt", "Allows deleting of DeliveryReceipt.");
	Permission VoidDeliveryReceipt = new Permission(Sales, DELIVERY_RECEIPT, "Void DeliveryReceipt", "Allows voiding of DeliveryReceipt.");
	Set<Permission> AllForDeliveryReceipt = new HashSet<Permission>( Arrays.asList(CreateDeliveryReceipt, ViewDeliveryReceipt, UpdateDeliveryReceipt, DeleteDeliveryReceipt, VoidDeliveryReceipt) );
	
	// SalesInvoice-related permissions
	Permission CreateSalesInvoice = new Permission(Sales, SALES_INVOICE, "Create SalesInvoice", "Allows creating of SalesInvoices.");
	Permission ViewSalesInvoice = new Permission(Sales, SALES_INVOICE, "View SalesInvoice", "Allows viewing of SalesInvoice information.");
	Permission UpdateSalesInvoice = new Permission(Sales, SALES_INVOICE, "Update SalesInvoice", "Allows updating of SalesInvoice information.");
	Permission DeleteSalesInvoice = new Permission(Sales, SALES_INVOICE, "Delete SalesInvoice", "Allows deleting of SalesInvoice.");
	Permission PostSalesInvoice = new Permission(Sales, SALES_INVOICE, "Post SalesInvoice", "Allows posting of SalesInvoice.");
	Set<Permission> AllForSalesInvoice = new HashSet<Permission>( Arrays.asList(CreateSalesInvoice, ViewSalesInvoice, UpdateSalesInvoice, DeleteSalesInvoice, PostSalesInvoice) );
	
	// Collection-related permissions
	Permission CreateCollection = new Permission(Sales, COLLECTION, "Create Collection", "Allows creating of Collections.");
	Permission ViewCollection = new Permission(Sales, COLLECTION, "View Collection", "Allows viewing of Collection information.");
	Permission UpdateCollection = new Permission(Sales, COLLECTION, "Update Collection", "Allows updating of Collection information.");
	Permission DeleteCollection = new Permission(Sales, COLLECTION, "Delete Collection", "Allows deleting of Collection.");
	Permission PostCollection = new Permission(Sales, SALES_INVOICE, "Post Collection", "Allows posting of Collection.");
	Set<Permission> AllForCollection = new HashSet<Permission>( Arrays.asList(CreateCollection, ViewCollection, UpdateCollection, DeleteCollection, PostCollection) );
	
	
	// Reports-related permissions
	Permission ViewCustomerLedgerReport = new Permission(Sales, REPORT_CUSTOMER_LEDGER, "View Customer Ledger Report", "Allows viewing of customer ledger report.");
	Set<Permission> AllForCustomerLedgerReport = new HashSet<Permission>( Arrays.asList(ViewCustomerLedgerReport) );
	
	Permission ViewCustomerSalesReport = new Permission(Sales, REPORT_CUSTOMER_SALES, "View Customer Sales Report", "Allows viewing of customer sales report.");
	Set<Permission> AllForCustomerSalesReport = new HashSet<Permission>( Arrays.asList(ViewCustomerSalesReport) );
	
	Permission ViewProductSalesReport = new Permission(Sales, REPORT_PRODUCT_SALES, "View Product Sales Report", "Allows viewing of product sales report.");
	Set<Permission> AllForProductSalesReport = new HashSet<Permission>( Arrays.asList(ViewProductSalesReport) );
	
//	Permission ViewMonthlyGroupSalesReport = new Permission(Sales, REPORT_MONTHLY_GROUP_SALES, "View Monthly Group Sales Report", "Allows viewing of monthly group sales report.");
//	Set<Permission> AllForMonthlyGroupSalesReport = new HashSet<Permission>( Arrays.asList(ViewMonthlyGroupSalesReport) );
	
	Permission ViewSalesmanSalesReport = new Permission(Sales, REPORT_SALESMAN_SALES, "View Salesman Sales Report", "Allows viewing of salesman sales report.");
	Set<Permission> AllForSalesmanSalesReport = new HashSet<Permission>( Arrays.asList(ViewSalesmanSalesReport) );

	Permission ViewIndividualSalesmanSalesReport = new Permission(Sales, REPORT_INDIV_SALESMAN_SALES, "View Individual Salesman Sales Report", "Allows viewing of individual salesman sales report.");
	Set<Permission> AllForIndividualSalesmanSalesReport = new HashSet<Permission>( Arrays.asList(ViewIndividualSalesmanSalesReport) );

	Permission ViewIndividualSalesmanCommissionReport = new Permission(Sales, REPORT_INDIV_SALESMAN_COMM, "View Individual Salesman Commission Report", "Allows viewing of individual salesman commission report.");
	Set<Permission> AllForIndividualSalesmanCommissionReport = new HashSet<Permission>( Arrays.asList(ViewIndividualSalesmanCommissionReport) );

	Permission ViewOutstandingReceivablesReport = new Permission(Sales, REPORT_OUTSTANDING_RECEIVABLES, "View Outstanding Receivables Report", "Allows viewing of outstanding receivables report.");
	Set<Permission> AllForOutstandingReceivablesReport = new HashSet<Permission>( Arrays.asList(ViewOutstandingReceivablesReport) );
	
	Permission ViewDeliveryReceiptsReport = new Permission(Sales, REPORT_DELIVERY_RECEIPTS, "View Delivery Receipts Report", "Allows viewing of delivery receipts report.");
	Set<Permission> AllForDeliveryReceiptsReport = new HashSet<Permission>( Arrays.asList(ViewDeliveryReceiptsReport) );
	
	Permission ViewIndividualSOAReport = new Permission(Sales, REPORT_INDIVIDUAL_SOA, "View Individual SOA Report", "Allows viewing of individual SOA report.");
	Set<Permission> AllForIndividualSOAReport = new HashSet<Permission>( Arrays.asList(ViewIndividualSOAReport) );
	
	Permission ViewCustomerAgingReport = new Permission(Sales, REPORT_CUSTOMER_AGING, "View Customer Aging Report", "Allows viewing of customer aging report.");
	Set<Permission> AllForCustomerAgingReport = new HashSet<Permission>( Arrays.asList(ViewCustomerAgingReport) );
	
	Permission ViewCommissionReport = new Permission(Sales, REPORT_COMMISSION, "View Commissino Report", "Allows viewing of commission report.");
	Set<Permission> AllForCommissionReport = new HashSet<Permission>( Arrays.asList(ViewCommissionReport) );
	
	@SuppressWarnings("serial")
	Set<Permission> All = new HashSet<Permission>() {
			{
				addAll(AllForProduct);
				addAll(AllForSalesman);
				addAll(AllForCustomer);
				addAll(AllForCheck);
				addAll(AllForMonthlyTotal);
				
				addAll(AllForDeliveryReceipt);
				addAll(AllForSalesInvoice);
				addAll(AllForCollection);
				addAll(AllForDebitMemo);
				addAll(AllForCreditMemo);
				addAll(AllForAdvancePayment);
				addAll(AllForAppliedAdvancePayment);
				
				addAll(AllForCustomerLedgerReport);
				addAll(AllForCustomerSalesReport);
				addAll(AllForProductSalesReport);
//				addAll(AllForMonthlyGroupSalesReport);
				addAll(AllForSalesmanSalesReport);
				addAll(AllForIndividualSalesmanSalesReport);
				addAll(AllForIndividualSalesmanCommissionReport);
				addAll(AllForOutstandingReceivablesReport);
				addAll(AllForIndividualSOAReport);
				addAll(AllForDeliveryReceiptsReport);
				addAll(AllForCustomerAgingReport);
				addAll(AllForCommissionReport);
				
			}
		};

}
